#!/bin/bash

PATH"../src"

qsub_default="qsub -d $(pwd) -j oe -m eba -M pedosb@gmail.com"

echo mpirun $PATH"/energy_estimation.py" -l etc/wav_list |\
	 $qsub_default -N front-end

for dtw_r in 600 800 1000 1200 1400 1600 1800 2000 2500 3000
do
	for i in $(seq 5)
	do
		conf="user_"$dtw_r"_"$i".cfg"
		rm -rf $conf
		printf "%s\n%s\n\n%s\n%s\n%s"\
			"[dtw]"\
			"r = $dtw_r"\
			"[files]"\
			"template = %(model_dir)s/template_r"$dtw_r"_$i"\
			"result_file = %(model_dir)s/result_r"$dtw_r"_$i"\
			>> $conf
		qsub_default=$qsub_default" -v DTW_CONFIG=$conf"
		id=$(echo mpirun $PATH"/train.py" |\
			$qsub_default -N "t-$conf")
		echo $id
		id=$(echo mpirun $PATH"/decode.py" |\
			$qsub_default -N "d-$conf" -W "depend=afeterok:$id")
		echo $id
	done
done
